import { RouteRecordRaw } from "vue-router";
import ACCESS_ENUM from "@/access/ACCESS_ENUM";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "管理",
    component: () => import("../layouts/BasicLayout.vue"),
    redirect: "/home",
    meta: { hideInMenu: true },
    children: [
      {
        path: "/home",
        name: "首页",
        component: () => import("../views/manage/HomeView.vue"),
      },
      {
        path: "/list/question",
        name: "问题列表",
        component: () => import("../views/manage/question/ListQuestion.vue"),
      },
      {
        path: "/list/question/submit",
        name: "提交列表",
        component: () =>
          import("../views/manage/question/ListQuestionSubmit.vue"),
      },
      {
        path: "/manage/question",
        name: "问题管理",
        meta: { access: ACCESS_ENUM.ADMIN },
        component: () => import("../views/manage/question/ManageQuestion.vue"),
      },
      {
        path: "/detail/question/:id",
        name: "问题详情",
        props: true,
        meta: { hideInMenu: true, access: ACCESS_ENUM.USER },
        component: () => import("../views/manage/question/DetailQuestion.vue"),
      },
      {
        path: "/create/question",
        name: "新建问题",
        meta: { access: ACCESS_ENUM.ADMIN, hideInMenu: true },
        component: () =>
          import("../views/manage/question/CreateQuestionView.vue"),
      },
      {
        path: "/update/question",
        name: "更新问题",
        meta: { access: ACCESS_ENUM.ADMIN, hideInMenu: true },
        component: () =>
          import("../views/manage/question/UpdateQuestionView.vue"),
      },
      {
        path: "/about",
        name: "关于",
        component: () => import("../views/manage/AboutView.vue"),
      },
      {
        path: "/noAuth",
        name: "无权限",
        meta: { hideInMenu: true },
        component: () => import("../views/manage/NoAuthView.vue"),
      },
    ],
  },
  {
    path: "/login",
    name: "登录",
    meta: { hideInMenu: true },
    component: () => import("../views/LoginView.vue"),
  },
  {
    path: "/register",
    name: "注册",
    meta: { hideInMenu: true },
    component: () => import("../views/RegisterView.vue"),
  },
];

export default routes;
